package com.homeworkp8.DctorTest;


//10.编写Doctor类{name,age,job,gender,sal}
//相应的getter()和setter()方法，五个参数的构造器，
// 重写父类的equals()方法:public boolean equals(Object obj),
//并判断测试类中创建的两个对象是否相等。相等就是判断属性是否相同
public class Doctor {

    private String name;
    private int age;
    private String gender;
    private String job;
    private double salary;

    public Doctor(String name, int age, String gender, String job, double salary) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.job = job;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Name: " + name + "\tage: " + age + "\tgender: " + gender + "\tjob: " + job + "\tsalary: " + salary;
    }

    // 重写父类的equals()方法:public boolean equals(Object obj),
    // 并判断测试类中创建的两个对象是否相等。(相等就是判断属性是否相同)

    @Override//向下转型+过关斩将
    public boolean equals(Object obj) {

        if (this == obj) {//pan'duan
            return true;
        }
        if (!(obj instanceof Doctor)) {
            return false;
        }
        Doctor doctor = (Doctor) obj;
        return doctor.getName().equals(this.name)
                && doctor.getAge() == this.age
                && doctor.getGender().equals(this.gender)
                && doctor.getJob().equals(this.job)
                && doctor.getSalary() == this.salary;


    }
}
